{% extends 'backend/backend_base.html' %}
{% load static %}


{% block articles %}
    <table class="table table-striped table-hover">
        <thead>
        <tr>
            <th>文章id</th>
            <th>文章标题</th>
            <th>发布时间</th>
            <th>点赞数</th>
            <th>点踩数</th>
            <th>操作</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        {% for article in page.object_list %}
            <tr>
                <th scope="row">{{ article.id }}</th>
                <td>
                    <a href="/{{ article.blog.user.username }}/articles/{{ article.id }}.html">{{ article.title }}</a>
                </td>
                <td>{{ article.update_time|date:'Y-m-d' }}</td>
                <td>{{ article.up_num }}</td>
                <td>{{ article.down_num }}</td>
                <td><a href="{% url 'del_article_name' article.id %}" class="btn btn-info">删除</a></td>
                <td><a href="{% url 'edit_article_name' article.id %}" class="btn btn-success">编辑</a></td>
            </tr>
        {% endfor %}
        </tbody>
    </table>
    {# 后台管理分页 #}
    <div class="text-center">
                        <nav aria-label="Page navigation">
                            <ul class="pagination">
                                {# 判断当前页是否有上一页(针对向左的箭头按钮) #}
                                {% if page.has_previous %}
                                    <li>
                                        {# 如果有上一页就跳到上一页 #}
                                        <a href="/backend/?page_num={{ page.previous_page_number }}"
                                           aria-label="Previous">
                                            <span aria-hidden="true">&laquo;</span>
                                        </a>
                                    </li>
                                {% else %}
                                    {# 如果没有上一页,就将该按钮禁用 #}
                                    <li class="disabled">
                                        <a href="" aria-label="Previous">
                                            <span aria-hidden="true">&laquo;</span>
                                        </a>
                                    </li>
                                {% endif %}

                                {# 从页码列表中循环取出页码与当前页做对比 #}
                                {% for foo in page_range %}
                                    {% if current_page == foo %}
                                        {# 如果是当前页,就将当前页按钮变成激活状态(蓝色) #}
                                        <li class="active"><a href="/backend/?page_num={{ foo }}">{{ foo }}</a></li>
                                    {% else %}
                                        {# 如果不是则不变色 #}
                                        <li><a href="/backend/?page_num={{ foo }}">{{ foo }}</a></li>
                                    {% endif %}

                                {% endfor %}

                                {# 判断但前页是否有下一页(针对向右的箭头按钮) #}
                                {% if page.has_next %}
                                    <li>
                                        {# 如果有则跳转到下一页 #}
                                        <a href="/backend/?page_num={{ page.next_page_number }}" aria-label="Next">
                                            <span aria-hidden="true">&raquo;</span>
                                        </a>
                                    </li>
                                {% else %}
                                    {# 没有下一页则将按钮禁用 #}
                                    <li class="disabled">
                                        <a href="" aria-label="Next">
                                            <span aria-hidden="true">&raquo;</span>
                                        </a>
                                    </li>
                                {% endif %}

                            </ul>
                        </nav>
                    </div>

{% endblock %}


{% block files %}
空空如也1...
{% endblock %}


{% block phones %}
空空如也2...
{% endblock %}


{% block email %}
空空如也3...
{% endblock %}


{% block script_left %}

{% endblock %}